(function ($) {

AjaxSolr.theme.prototype.result = function (doc, response) {
  var link = '';
  if(doc.lat != undefined) {
     link = ' <img style="cursor:pointer" src="img/gmap_marker_default.gif" onclick="loadTitleMap('+doc.lat+','+doc.lng+',event);"/>';
  }
  var title =   AjaxSolr.theme.prototype.title  (doc, response);
  var snippet = AjaxSolr.theme.prototype.snippet(doc, response);
  var output = '<div class="result"><h2><a href="'+doc.uri+'">' + title + '</a>'+link+'</h2>';
  output += '<h4>'+doc.created+'</h4>';
  output += '<p>' + snippet + '</p></div>';
  return output;
};

AjaxSolr.theme.prototype.title = function (doc, response) {
	  var title = "";
	  
	  if (response && response.highlighting && response.highlighting[doc.id]) {
		  title += response.highlighting[doc.id].title;
	  }
	  else title += doc.title;
	  return title;
};

AjaxSolr.theme.prototype.snippet = function (doc, response) {
  if (response && response.highlighting && response.highlighting[doc.id]) {
	  var output = response.highlighting[doc.id].summary;
	  return output;
  }
  var output = doc.summary;
  return output;
};

AjaxSolr.theme.prototype.tag = function (facet, weight, handler) {
  return $('<a href="#" class="tagcloud_item"/>').html(facet.value+"&nbsp;("+facet.count+")").addClass('tagcloud_size_' + weight).click(handler);
};

AjaxSolr.theme.prototype.facet_link = function (value, handler) {
  return $('<a href="#"/>').text(value).click(handler);
};

AjaxSolr.theme.prototype.no_items_found = function () {
  return 'no items found in current selection';
};

AjaxSolr.theme.prototype.no_results = function () {
	  return 'no items found';
};

AjaxSolr.theme.prototype.no_facets = function () {
	  return 'no available facets';
};


})(jQuery);

